package com.lgx.mall.core.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;

import net.sf.json.JSONObject;

import com.lgx.common.entity.IdGenerator;

/**
 * 商品品牌
 * 
 * @author hezhuo
 *
 */
@Entity
@Table(name = "TM_BRAND")
public class Brand implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4988575053136954657L;

	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.BRAND_ID_GENERATOR)
	@TableGenerator(
			name = IdGenerator.BRAND_ID_GENERATOR,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.BRAND_ID_GENERATOR,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private Long id;
	
	/**
	 * 品牌名称
	 */
	private String name;
	
	/**
	 * 品牌描述
	 */
	private String description;
	
	private String imageUrl = "";
	
	private String url;
	
	private String isdelete = "0";
	
	private String layerOrder;
	
	@Transient
	private List<Brand> children = new ArrayList<Brand>();

	public List<Brand> getChildren() {
		return children;
	}

	public void setChildren(List<Brand> children) {
		this.children = children;
	}

	public String getLayerOrder() {
		return layerOrder;
	}

	public void setLayerOrder(String layerOrder) {
		this.layerOrder = layerOrder;
	}

	public String getImageUrl() {
		if(imageUrl==null) {
			return "";
		}
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getIsdelete() {
		return isdelete;
	}

	public void setIsdelete(String isdelete) {
		this.isdelete = isdelete;
	}

	@Override
	public String toString() {
		JSONObject obj = new JSONObject();
		
		obj.put("id", this.getId());
		obj.put("name", this.getName());
		obj.put("description", this.getDescription());
		obj.put("imageUrl", this.getImageUrl());
		return obj.toString();
	}

}
